package com.wc.AlgoOJ_train.train2_DP训练.c6.DP0301;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/13 14:52
 * @description 统计人数
 */
public class Main {
    static int maxN = (int) 1e5 + 7;
    static int[] dp = new int[maxN];
    // 领接表
    static HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
    static int n;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            map.put(i, new ArrayList<>());
        }
        int u, v;
        for (int i = 2; i <= n; i++) {
            u = sc.nextInt();
            v = i;
            map.get(u).add(v);
        }
        dfs(1);
        out.print(dp[1]);
        for (int i = 2; i <= n; i++) {
            out.print(' ');
            out.print(dp[i]);
        }
        out.println();
        out.flush();
    }

    static void dfs(int u) {
        if (dp[u] != 0) {
            return;
        }

        ArrayList<Integer> arr = map.get(u);
        for (int v : arr) {
            dfs(v);
            dp[u] += dp[v];
        }
        // 把自己加上
        dp[u]++;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}
